import Vue from 'vue'
// 引入Vuex
import Vuex from 'vuex'
import menus from "@/store/modules/menus";
// 使用Vuex
Vue.use(Vuex)

// 准备actions --- 用于响应组件中的动作
const actions = {
    getSysUserByServer(context, username) {
        this.axios.get("/sysUser/getMessage", {
            params:{
                username: username
            }
        }).then(rep => {
            console.log(rep.data.data)
            // context.commit("setUser",rep.data.data)
            }
        )
    }
}
// 准备mutation --- 用于操作数据 (state)
const mutations = {
}
// 准备state --- 用于储存数据
const state = {
    sysUser: {
        username: "admin",
        avatar: "https://image-1300566513.cos.ap-guangzhou.myqcloud.com/upload/images/5a9f48118166308daba8b6da7e466aab.jpg",
        email: "123@qq.com",
        city: "广州",
        token:''
    },
}
// 准备getter --- 用于将state中的数据进行加工返回
const getters = {}
const modules = {
    menus
}
// 创建并暴露store
export default new Vuex.Store({
    actions,
    mutations,
    state,
    getters,
    modules
})
